<template>
  <div class="search-pagination">
    <v-page
      :page-size-menu="page_size_menu"
      v-model="pageNow"
      :info="false"
      language="en"
      :total-row="amount"
      @page-change="pageChange"
      :border="false"
      align="left"
    ></v-page>
  </div>
</template>

<script>
export default {
  name: "SearchPagination",
  props: {
    amount: Number,
    page_size_menu: {
      default: false
    }
  },
  data() {
    return {
      pageNow: parseInt(this.$route.query.page ?? 1)
    };
  },
  watch: {
  },
  methods: {
    pageChange(page) {
      const r = Object.assign({}, this.$route);
      const path = r.path;
      const query = Object.assign({}, r.query);
      if (page.pageNumber === 1 && this.$route.query.page == undefined) {
        return;
      }
      if (page.pageNumber == 1 && this.$route.query.page != undefined) {
        delete query.page;
      }
      else {
        query.page = page.pageNumber;
      }
      console.log(page);
      this.$router.push({
        path: path,
        query: query
      });
    }
  },
  components: {
  },
};
</script>

<style scoped lang="scss">
.search-pagination {
  
}
</style>
